
    /**  
    * @Title: MyDefaultCookieSerializer.java
    * @Package com.efast.cafe.framework.session
    * @Description: TODO(用一句话描述该文件做什么)
    * @author Administrator
    * @date 2018年9月6日
    * @version V1.0  
    */
    
package com.efast.cafe.framework.session;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.session.web.http.DefaultCookieSerializer;

import com.efast.cafe.framework.constant.FrameConstant;
import com.efast.cafe.util.ConfigUtil;

/**
    * @ClassName: MyDefaultCookieSerializer
    * @Description: TODO(这里用一句话描述这个类的作用)
    * @author Administrator
    * @date 2018年9月6日
    *
    */

public class MyDefaultCookieSerializer extends DefaultCookieSerializer{

	private static final Boolean isSecure = Boolean.parseBoolean(ConfigUtil.getValue("cafe.ssl"));
	
	
	
	
	@Override
	public List<String> readCookieValues(HttpServletRequest request) {
		this.setCookiePath("/");
		this.setCookieName(FrameConstant.SESSION_KEY);
		this.setUseSecureCookie(isSecure);
		this.setUseBase64Encoding(true);
		this.setUseHttpOnlyCookie(true);
		return super.readCookieValues(request);
	}
	
	    
	@Override
	public void writeCookieValue(CookieValue cookieValue) {
		this.setCookiePath("/");
		this.setCookieName(FrameConstant.SESSION_KEY);
		this.setUseSecureCookie(isSecure);
		this.setUseBase64Encoding(true);
		this.setUseHttpOnlyCookie(true);
		super.writeCookieValue(cookieValue);
	}
}
